﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace YHWE.Web
{
    using JULONG.WEB.Library.Account;
    // Note: For instructions on enabling IIS6 or IIS7 classic mode, 
    // visit http://go.microsoft.com/?LinkId=9394801

    public class MvcApplication : System.Web.HttpApplication
    {
        public static void RegisterGlobalFilters(GlobalFilterCollection filters)
        {
            filters.Add(new HandleErrorAttribute());
        }

        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                "Default", // Route name
                "{controller}/{action}/{id}", // URL with parameters
                new { controller = "Home", action = "Index", id = UrlParameter.Optional }, // Parameter defaults
                  new string[] { "YHWE.Web.Controllers" }
            );
            routes.MapRoute(
                "paging", // 路由名称
                "{controller}/{action}/{id}/{page}", // 带有参数的 URL
                new { controller = "Home", action = "Index", id = 0, page = UrlParameter.Optional }, // 参数默认值
                new string[] { "YHWE.Web.Controllers" }
            );
        }

        protected void Application_Start()
        {

            AreaRegistration.RegisterAllAreas();

            RegisterGlobalFilters(GlobalFilters.Filters);

            //manage过滤器
            authorityFilter manageFilter = new authorityFilter(new YHWE.Web.Areas.manage.Models.manageAuthority());
            GlobalFilters.Filters.Add(manageFilter);

            RegisterRoutes(RouteTable.Routes);

            var xx = new YHWE.Web.Areas.manage.Models.dbInit();
            xx.start();
        }
    }
}